package middleware

import (
	"github.com/kataras/iris/v12"
	"log"
	"time"
)

func Trace(ctx iris.Context) {
	defer trace(ctx)()
	ctx.Next()
}

func trace(ctx iris.Context) func() {
	start := time.Now()
	return func() {
		log.Printf("ip(%s) - (%s) - %s", ctx.RemoteAddr(), time.Since(start), ctx.Path())
	}
}
